<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<div th:replace="/common/header :: header"></div>
<body>

<div class="login_bac">
	<form action="" name="" method="post">
		<div class="login_warp">
			<img src="images/logo.png" class="login_img">
			<div class="lg_tit clearfix">
				<i class="lg_tfl"></i>
				<p class="lg_sign">Sign In</p>
				<i class="lg_tfr"></i>
			</div>
			<div class="clearfix lg_ipu">
				<img src="images/a1.png" class="lg_limg">
				<input type="text" name="phone" id="phone" class="lo_input" placeholder="Phone"  >
			</div>
			<div class="clearfix lg_ipu">
				<img src="images/a2.png" class="lg_limg">
				<input type="password" name="password" id="password" class="lo_input" placeholder="Password" AUTOCOMPLETE="off" >
			</div>
			<div class="clearfix lg_ipu">
				<img src="images/a3.png" class="lg_limg">
				<input type="text" name="code" id="code" class="lo_input" placeholder="Code" AUTOCOMPLETE="off" >
				<img src="http://placehold.it/90x40" class="lg_code"  id="lg_code">
			</div>
			<div class="clearfix lg_wpr">
				<div class="lg_lgoin" onclick="login()">Login</div>
				<div class="lg_Reg" onclick="location='/regist.html'">Reg</div>
			</div>
		</div>
	</form>
</div>
<div class="lg_bot">
	<div class="clearfix lg_boa">
		<a href="#">Contact Us</a>
		<a href="#">About Us</a>
		<a href="#">Readme Before Use</a>
	</div>
	<p class="lg_boits">@Better Price Better Go</p>
</div>
<script type="text/javascript">
	//每次登陆设置一个版本号version，方便后续调用
	window.localStorage.setItem("version",JSON.stringify(new Date().getTime()));
	document.write('<script src="modules/bus4u_common.js?version=' + window.localStorage.getItem("version") + '"><\/script>');
</script>
<script th:inline="javascript">
	var a = $(window).height();
	$(".login_bac").height(a);

	$("#lg_code").click(function(){
		Bus4uUtil.createCodeLink(Bus4uUtil.serverUrl,"lg_code");//生成 验证码图片 链接
	});
	/*加载layui组件*/
	layui.use([ 'laydate', 'laypage', 'layer', 'table', 'carousel', 'upload',
		'element' ], function() {
		var laydate = layui.laydate //日期
				, laypage = layui.laypage //分页
				, layer = layui.layer //弹层
				, table = layui.table //表格
				, carousel = layui.carousel //轮播
				, upload = layui.upload //上传
				, element = layui.element; //元素操作

	});
	/**
	 * 登陆ajax
	 */
	function login(){
		// console.log("点击登陆")
		let url = Bus4uUtil.serverUrl+"pc/user/login";
		let data = {
			"phone":$("#phone").val(),
			"password":$("#password").val(),
			"code":$("#code").val()
		};
		if($.trim($("#phone").val())==""){
			layer.msg("Phone不能为空");
			return false;
		}else if($.trim($("#password").val())==""){
			layer.msg("Password不能为空");
			return false;
		}else if($.trim($("#code").val())==""){
			layer.msg("Code不能为空");
			return false;
		}
		$.ajax({
			url:url,
			type:"POST",
			data:data,
			success:function(d){
				// console.log("code="+d.code);
				if(d.code == 0){
					// console.log("验证成功！");

					Bus4uUtil.setData("orderStatusCodeList",d.result.orderStatusCodeList);//将订单状态代码列表放入前端缓存中
					// console.log("orderStatusCodeList1="+d.result.orderStatusCodeList)
					// console.log("orderStatusCodeList2="+Bus4uUtil.getData("orderStatusCodeList"))
					location.href = "/index.html"//登录成功，页面跳转index
				}else if(d.code == 10){
					// console.log("伪登陆成功！");
					location.href = "/oldUserInfoSupplement.html"//伪登陆成功，页面跳转旧用户数据补全页面
				}else{
					layer.msg(d.msg);
				}
			},
			error:function(){
				console.log("error");
			}
		});
	}

	$(function(){
		Bus4uUtil.createCodeLink(Bus4uUtil.serverUrl,"lg_code");//生成 验证码图片 链接
	})
	//enter 键提交
	document.onkeydown=function(event){
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if(e && e.keyCode==13){
			$('.lg_lgoin').click();
		}
	};

</script>


<script language="JavaScript">
	if (window != top) top.location.href = location.href;
</script>
</body>
</html>
